﻿using System;
using System.Collections.Generic;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Windows;
using DTC.Database;

namespace DTC
{
    /// <summary>
    /// Interaction logic for App.xaml
    /// </summary>
    public partial class App : Application
    {
        private static DatabaseInterface dbi = new DatabaseInterface();
        public static DatabaseInterface DBI
        {
            get { return dbi; }
        }

        private void StackPanel_MouseLeftButtonDown(object sender, System.Windows.Input.MouseButtonEventArgs e)
        {
            Window wnd = GetStackPanelWindow(sender);
            if (wnd != null)
                wnd.DragMove();
        }
        private Window GetStackPanelWindow(object sender)
        {
            //StackPanel stp = (StackPanel)sender;
            //Border brd = (Border)stp.Parent;
            //Grid grd = (Grid)brd.Parent;
            //brd = (Border)grd.Parent;
            FrameworkElement brd = (FrameworkElement)sender;
            return (Window)brd.TemplatedParent;
        }

        private void CloseButton_Click(object sender, RoutedEventArgs e)
        {
            Window wnd = GetStackPanelWindow(sender);
            if (!wnd.ShowInTaskbar)
                wnd.DialogResult = false;
            else
                wnd.Close();
        }

        private void AcceptBtn_Click(object sender, RoutedEventArgs e)
        {
            Window wnd = GetStackPanelWindow(sender);
            if (!wnd.ShowInTaskbar)
                wnd.DialogResult = true;
            else
                wnd.Close();
        }
    }
}
